import axios from "axios";
import Vue from "vue";
import Vuex from 'vuex';

Vue.use(Vuex)

const actions = {
    getstate(context){
        axios.get('http://localhost:8080/api/login/status'+ "?" + Date.now()).then( (response) => {
           
            context.commit('Getstate',response.data.data)
        })
    } 
}

const mutations = {
      Getstate(state,index){
    
          if (index.account) {
           
               state.signIn = true;
             state.data = index
              
            
            
          }else {
             
              state.signIn = false;
           
              
            
              
          }
      } 
}

const state = {
    data:'',
    signIn:false
}

export default new Vuex.Store({
    actions,
    mutations,
    state,
})